package com.bonc.ioc.interceptor;

import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @Description 意见插入拦截 IP，1小时只能提交三次意见
 * @Author wxf
 * @Date 2021/4/21
 **/
@Configuration
public class OpinionInsert extends WebMvcConfigurerAdapter {

    @Bean
    public OpinionInterceptor opinionInterceptor(){
        return new OpinionInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        InterceptorRegistration ir = registry.addInterceptor(opinionInterceptor());
        ir.addPathPatterns("/opinion/insert");
    }
}
